package com.example.demo.mapper;

import com.example.demo.domain.HbdItemDictDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HbdItemDictMapper {

    @Select("SELECT "
            +"* "
            + "FROM hbd_item_dict hid "
            + "LEFT JOIN hbd_case_phase_data_item data "
            + "ON hid.item_code = data.item_code "
            + "AND data.data_id = 176044402022680581 "
            + "WHERE hid.parent_code = 0 AND hid.item_code <50"
    )
    @Results({
            @Result(column = "item_code",property = "itemCode"),
            @Result(column = "item_name",property = "itemName"),
            @Result(column = "parent_code",property = "parentCode"),
            @Result(column = "item_value",property = "itemValue")
    })
    List<HbdItemDictDO> listRoots();

    @Select("SELECT "
                +"* "
            + "FROM hbd_item_dict hid "
            + "LEFT JOIN hbd_case_phase_data_item data "
            + "ON hid.item_code = data.item_code "
            + "AND data.data_id = 176044402022680581 "
            + "WHERE hid.parent_code = #{parentCode} AND hid.item_code <50"
            )
    @Results({
            @Result(column = "item_code",property = "itemCode"),
            @Result(column = "item_name",property = "itemName"),
            @Result(column = "parent_code",property = "parentCode"),
            @Result(column = "item_value",property = "itemValue")
    })
    List<HbdItemDictDO> listChildren(@Param("parentCode") Integer parentCode);

}
